export CUDA_VISIBLE_DEVICES=$1

python train_flux_kontext/train_flux_kontext_posenv2_diffusers.py \
  --pretrained_model_name_or_path="/data/models/FLUX.1-Kontext-dev" \
  --root_dir="/mnt/nas/shengjie/datasets/KontextRefControl_poseenv"\
  --output_dir="/mnt/nas/shengjie/posenv_output_0918_2/" \
  --style_type="refcontrolPoseEnv" \
  --mixed_precision="bf16" \
  --resolution=1024 \
  --train_batch_size=1 \
  --gradient_accumulation_steps=2 \
  --guidance_scale=2.5 \
  --rank=16 \
  --lora_alpha=16 \
  --learning_rate=1e-4 \
  --lr_scheduler="cosine" \
  --lr_warmup_steps=0 \
  --max_train_steps=8000 \
  --optimizer="adamw" \
  --use_8bit_adam \
  --gradient_checkpointing \
  --checkpointing_steps=500 \
  --validation_prompt="[refcontrolPoseEnv] change pose and env to photo with reference from left side,change person to photo with refence from right side." \
  --seed=42

# --pretrained_model_name_or_path: Path to the local base model checkpoint.
# --pretrained_model_name_or_path : 本地基础模型检查点的路径。
# --output_dir: Directory to save the trained LoRA weights and checkpoints.
# --output_dir : 用于保存训练的 LoRA 权重和检查点的目录。
# --style_type: The name of the style to train on. This must match one of the subdirectories in your dataset folder.
# --style_type : 要训练的风格名称。必须与数据集文件夹中的子目录之一匹配。
# --mixed_precision: Use bf16 or fp16 for faster training.
# --mixed_precision : 使用 bf16 或 fp16 以加快训练速度。
# --resolution: The training image resolution. Should match the base model's optimal resolution (1024 for FLUX.1).
# --resolution : 训练图像分辨率。应与基础模型的最佳分辨率匹配（FLUX.1 为 1024）。
# --train_batch_size: Batch size per GPU.
# --train_batch_size : 每个 GPU 的批处理大小。
# --rank & --lora_alpha: The rank and alpha for the LoRA layers. A higher rank allows for more expressive power at the cost of a larger model size.
# --rank & --lora_alpha : LoRA 层的秩和 alpha。更高的秩允许在模型尺寸更大的情况下获得更强的表达能力。
# --learning_rate: The initial learning rate.
# --learning_rate : 初始学习率。
# --max_train_steps: Total number of training steps.
# --max_train_steps : 训练步骤总数。
# --validation_prompt: A prompt used to generate sample images for validation.
# --validation_prompt : 用于生成验证样本图像的提示。
# --checkpointing_steps: Save a full training state every N steps.
# --checkpointing_steps : 每 N 步保存一个完整的训练状态。